package qiangqiang.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import qiangqiang.entity.MessageBoard;
import qiangqiang.service.MessageBoardService;
import qiangqiang.util.ResultUtil;
import qiangqiang.vo.ResultVO;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by q on 2017/10/17.
 */
@Controller
@RequestMapping("/message")
public class MessageBoardController {

    @Autowired
    private MessageBoardService service;

    @RequestMapping(value = "/add",produces="application/json;charset=UTF-8")
    @ResponseBody
    public ResultVO addMessage(MessageBoard messageBoard){
        System.out.println(messageBoard.getContent());
        service.addMessage(messageBoard);
        return ResultUtil.success();
    }
    @RequestMapping("/test")
    @ResponseBody
    public ResultVO test(){
        return ResultUtil.success();
    }

    @RequestMapping(value = "/getAll",method = RequestMethod.GET)
    @ResponseBody
    public ResultVO<MessageBoard> getAllMessage(){
        List<MessageBoard> list=service.getAllMessage();
        return ResultUtil.success(list);
    }
    @RequestMapping(value = "/updateLikeNumber/{mId}",method = RequestMethod.GET)
    @ResponseBody
    public ResultVO<Long> updateLikeNumber(@PathVariable("mId") long mId){
       return ResultUtil.success(service.updateLikeNumber(mId));
  }

}
